<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/fuman/js/purchase.js" ></script>

<script>
function addorder()
{
	$('#addstorageform').modal('show');	
}
function stoorder()
{
  $('#staddstorageform').modal('show');	
}
function onsavehand()
{
	var tostock = $("#tostock").val();
	if(tostock =="")
	{
		alert("请指定入库仓库！");
		return;	
	}
	var goodslist = $("#goodslist").val();
	if(goodslist =='')
	{
		alert("请填写入库SKU");
		return;	
	}
	$("#attributeform").submit();
	$("#addstorageform").modal('hide');	
}

function newonsavehand()
{
	var istostock = $("#istostock").val();
	if(istostock =="")
	{
		alert("请指定出库仓库！");
		return;	
	}
	var togoodslist = $("#togoodslist").val();
	if(togoodslist =='')
	{
		alert("请填写入库SKU");
		return;	
	}
	$("#newattributeform").submit();
	$("#staddstorageform").modal('hide');		
}

function delstock(id)
{
		$.post("/purchase/ajaxbutton", {"op": "delstock","id":id},
	  function(data){
			document.location.href = "/purchase/handstorage";
	   },"json");
}
function confirk(id)
{
	$("#co"+id).hide();
	$.post("/purchase/ajaxbutton", {"op": "confirk","id":id},
  function(data){
		document.location.href = "/purchase/handstorage";
   },"json");	
}
</script>

<title>手动入库</title>
<body class="withvernav">
<div class="bodywrapper">
{{include file='/public/orderleft.tpl'}}
<div class="centercontent">
  <div class="pageheader notab">
    <h1 class="pagetitle">手动入库</h1>
    <span class="pagedesc"><br></span>
    <div class="menulist">
    <ul class="profile_summary">
       <li class="current"><a href="javascript:void(0)" onClick="addorder()" class=""><span>手动入库</span></a></li>
        <li class="current"><a href="javascript:void(0)" onClick="stoorder()" class=""><span>手动出库</span></a></li>
   
        </ul>
  </div>
  </div>
  <!--pageheader-->
  <div id="contentwrapper" class="contentwrapper">
    <div id="basicform" class="subcontent"> 
      <!--搜索栏-->
      <div> </div>
      <div style="clear: both"></div>
      <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
    </div>
    <form class="stdform stdform2" method="get" id="search" action="/purchase/handstorage">
      <div class="tableoptions">
       
      
        <select name="cang">
              <option value="">-操作仓库-</option>
              {{foreach from=$warehouses item=li key=key}}
                <option value="{{$li.id}}" {{if $cang==$li.id}} selected{{/if}}>
                    {{$li.storagename}}
                </option>
              {{/foreach}}
          </select>
        <select name="status" id="status">
          <option value="">-状态-</option>
         
          <option value="2" {{if $status=='2'}} selected{{/if}}>待处理</option>
          <option value="3" {{if $status=='3'}} selected{{/if}}>已处理</option>
        </select>
        
        <select name="ks" id="ks">
          <option value="">-出入库-</option>
         
          <option value="2" {{if $ks=='2'}} selected{{/if}}>出库操作</option>
          <option value="3" {{if $ks=='3'}} selected{{/if}}>入库操作</option>
         <option value="4" {{if $ks=='4'}} selected{{/if}}>质检入库</option>
         <option value="5" {{if $ks=='5'}} selected{{/if}}>封箱出库</option>
         
        </select>
       
       操作时间
        <input type="text"  name="starttime" value="{{$starttime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
        -
        <input type="text"  name="endtime" value="{{$endtime}} " onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker" />
      SKU
        :
        <input type="text" name="kw" id="kw" class="width200" value="{{$kw}}" placeholder="关键词" />
        &nbsp;
        <button class="btn btn-primary" id="searchbtn">Search</button>
        <input type='hidden' name='if_csv' id='if_csv'>
        <input type='hidden' name='isow' id='isow'>
        <input type='hidden' name='isno' id='isno'>
        <input type='hidden' name='que' id='que'>
      </div>
    </form>
    <!--搜索栏结束-->
    <table cellpadding="0" cellspacing="0" border="0" class="stdtable" style="table-layout: fixed;">
      <thead>
        <tr class="lbbt">
          <td width="3%"  bgcolor="#FEFFF1"><a onClick="allSelect('ppid[]')">全选</a></td>
          <td width="5%" bgcolor="#FEFFF1">类型 </td>
          <td width="8%" bgcolor="#FEFFF1">商品编号</td>
          <td width="22%"  bgcolor="#FEFFF1">商品名称</td>
          <td  bgcolor="#FEFFF1">操作仓库</td>
          <td  bgcolor="#FEFFF1">本次操作数</td>
          <td  bgcolor="#FEFFF1">原库存</td>
          <td  bgcolor="#FEFFF1">新库存</td>
          <td  bgcolor="#FEFFF1">状态</td>
           <td  width="10%"  bgcolor="#FEFFF1">操作时间</td>
          <td  bgcolor="#FEFFF1">操作人员</td>
          <td  bgcolor="#FEFFF1" >备注</td>
         
          <td  bgcolor="#FEFFF1" >操作</td>
        </tr>
      </thead>
      <tbody >
      
      {{foreach from=$orderlist item=li key=key}}
      <tr>
        <td ><input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.order_sn}}" /></td>
        <td valign="middle" style="position:relative;">{{if $li.istype==1}}手动入库{{/if}}{{if $li.istype==2}}手动出库{{/if}}{{if $li.istype==3}}质检入库{{/if}}{{if $li.istype==4}}质检出库{{/if}}{{if $li.istype==5}}封箱出库{{/if}}{{if $li.istype==6}}调拔入库{{/if}}{{if $li.istype==7}}调拔出库{{/if}}</td>
        <td valign="middle" style="position:relative;"><a href="/product/productlist?other={{$li.goods_sku}}" target="_blank"><font color="#6666FF">{{$li.goods_sku}}</font></a></td>
       
        <td valign="middle">{{$li.goods_name}}</td>
        <td style="position:relative;">{{$li.storagename}}</td>
        <td valign="middle">{{$li.goods_instock}}</td>
        <td class="cz">{{$li.oldnum}}</td>
        <td class="cz">{{$li.newnum}}</td>
       <td class="cz">{{if $li.status==0}}待处理{{/if}}{{if $li.status==1}}已处理{{/if}}</td>
        <td valign="middle">{{$li.waittime}}</td>
        <td valign="middle">{{$li.opername}}</td>
        <td>
          {{if $li.memo==''}}
        <span style="cursor:pointer" onClick="listTable.edit(this, 'savememohandstock','{{$li.id}}','{{$li.memo}}')">{{if $li.remark}}{{$li.remark}}{{else}}<font color="#CCCCCC">编辑备注</font>{{/if}}</span>
        {{else}}
        {{$li.memo}}
        {{/if}}
        </td>
        <td>
        {{if $li.istype==1}}
        	  {{if $li.status==0 &&  $li.goods_id >0}}<img src="/fuman/images/rk.jpg" onClick="confirk({{$li.id}})" id="co{{$li.id}}" style="cursor:pointer">
      		 	| <a href="#" onClick="delstock({{$li.id}})">删除</a>
             {{/if}}
        {{/if}}
        
        
         {{if $li.istype==2}}
        	  {{if $li.status==0 &&  $li.goods_id >0}} <a href="#"  id="co{{$li.id}}" onClick="confirk({{$li.id}})">处理出库</a>
      		 	| <a href="#" onClick="delstock({{$li.id}})">删除</a>
       		 {{/if}}
        {{/if}}
        
         {{if $li.status==1}}已处理{{/if}}
       
       	
        {{if  $li.goods_id ==0}}<a href="#" onClick="delstock({{$li.id}})"> | 删除</a>{{/if}}
       
        </td>
      </tr>
      {{/foreach}}
        </tbody>
      
    </table>
    <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
  </div>
</div>

<!-- 模态框（Modal）手动入库 -->
<form action="/purchase/savehandstorage"  method="post" name="attributeform" id="attributeform"  target="_self" >
<input type="hidden" name="istype" value="1">
  <div class="modal fade" id="addstorageform" tabindex="-1" role="dialog" aria-labelledby="returnaddattributeform" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">× </button>
          <h4 class="modal-title" id="returnaddattributeform"> 手动入库操作（一行一个） </h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="100">SKU： </td>
              <td align="left"><textarea name="goodslist" id="goodslist" cols="10" rows="10"></textarea></td>
            </tr>
           <tr>
              <td width="100">入库仓库： </td>
              <td align="left"> <select name="tostock" id="tostock" size="1" class="full_input">
              <option value="">请选择</option>
              {{foreach from = $storagelist key=key item=li}}
                <option value="{{$li.id}}">{{$li.storagename}}</option>
              {{/foreach}}
              </select></td>
            </tr>
             <tr>
              <td>注意： </td>
              <td align="left">格式说明：如A001,10,13.2换行 第一列sku*,第二列数量（可选），第三列采购价(可选)</td>
            </tr>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal"> 关闭 </button>
            <button type="button" class="btn btn-primary"  onclick="onsavehand()"> 提交 </button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>




<!-- 模态框（Modal）手动出库 -->
<form action="/purchase/savehandstorage"  method="post" name="newattributeform" id="newattributeform"  target="_self" >
<input type="hidden" name="istype" value="2">
  <div class="modal fade" id="staddstorageform" tabindex="-1" role="dialog" aria-labelledby="returnaddattributeform" aria-hidden="true">
    <div class="modal-dialog" style="width:740px;">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" 
               aria-hidden="true">× </button>
          <h4 class="modal-title" id="returnaddattributeform"> 手动出库（一行一个） </h4>
        </div>
        <div class="modal-body">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="100">SKU： </td>
              <td align="left"><textarea name="togoodslist" id="togoodslist" cols="10" rows="10"></textarea></td>
            </tr>
           <tr>
              <td width="100">出库仓库： </td>
              <td align="left"> <select name="istostock" id="istostock" size="1" class="full_input">
              <option value="">请选择</option>
              {{foreach from = $storagelist key=key item=li}}
                <option value="{{$li.id}}">{{$li.storagename}}</option>
              {{/foreach}}
              </select></td>
            </tr>
             <tr>
              <td>注意： </td>
              <td align="left">格式说明：如A001,10,13.2换行 第一列sku*,第二列数量（可选），第三列采购价(可选)</td>
            </tr>
          </table>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal"> 关闭 </button>
            <button type="button" class="btn btn-primary"  onclick="newonsavehand()"> 提交 </button>
          </div>
        </div>
        <!-- /.modal-content --> 
      </div>
      <!-- /.modal-dialog --> 
    </div>
  </div>
  <!-- /.modal -->
</form>


</body>
</html>